package cn.chenhuanming.shh.administer.entity.jpa;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * District entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "district", catalog = "house")
public class District implements java.io.Serializable {

	// Fields

	private Integer id;
	private String name;
	private District parent;
	private String code;
	private Short order;
	private Set<District> children = new HashSet<District>(0);
	private Set<House> houses = new HashSet<House>(0);
	private Set<Estate> estates = new HashSet<Estate>(0);

	// Constructors

	/** default constructor */
	public District() {
	}

	/** minimal constructor */
	public District(Integer id) {
		this.id = id;
	}

	/** full constructor */
	public District(Integer id, String name, District parent, String code,
			Short order, Set<House> houses, Set<Estate> estates) {
		this.id = id;
		this.name = name;
		this.parent = parent;
		this.code = code;
		this.order = order;
		this.houses = houses;
		this.estates = estates;
	}

	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", length = 270)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id")
	public District getParent() {
		return this.parent;
	}

	public void setParent(District parent) {
		this.parent = parent;
	}

	@Column(name = "code", length = 30)
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "order")
	public Short getOrder() {
		return this.order;
	}

	public void setOrder(Short order) {
		this.order = order;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
	public Set<District> getChildren() {
		return this.children;
	}

	public void setChildren(Set<District> children) {
		this.children = children;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "district")
	public Set<House> getHouses() {
		return this.houses;
	}

	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "district")
	public Set<Estate> getEstates() {
		return this.estates;
	}

	public void setEstates(Set<Estate> estates) {
		this.estates = estates;
	}

}